<template>
  <div>
    <el-form :inline="true" :model="form" class="demo-form-inline" style="text-align: left">
      <el-form-item label="负责区域">
        <el-select v-model="form.quyu" placeholder="请选择所在区域">
          <el-option label="请选择" value=""></el-option>
          <el-option label="操场" value="操场"></el-option>
          <el-option label="篮球场" value="篮球场"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="负责人员">
        <el-input v-model="form.name" placeholder="负责人员"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="load">查询</el-button>&nbsp;

        <el-button>新增</el-button>
      </el-form-item>
    </el-form>
    <template>
      <el-table
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column prop="scheduleNum" label="排班编号" width="180">
        </el-table-column>
        <el-table-column prop="area" label="负责区域" width="180">
        </el-table-column>
        <el-table-column prop="carNum" label="关联车辆" width="180">
        </el-table-column>
        <el-table-column prop="person" label="负责人" width="180">
        </el-table-column>
        <el-table-column prop="phone" label="负责人联系方式" width="180">
        </el-table-column>
        <el-table-column label="作业时间" width="180">
          <template slot-scope="scope">
            <span
              >{{ scope.row.workTimeStation }} -
              {{ scope.row.workTimeStop }}</span
            >
          </template>
        </el-table-column>
        <el-table-column prop="startTime" label="开始时间" width="180">
        </el-table-column>
        <el-table-column prop="endTime" label="结束时间" width="180">
        </el-table-column>
        <el-table-column label="操作" width="180">
          <template slot-scope="scope">
            <el-link type="danger" @click="fantian(scope.row.id)">修改</el-link>
            <el-link type="info" @click="shanchu(scope.row.id)">删除</el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="form.pageIndex"
      :page-sizes="[2, 4, 6, 8]"
      :page-size="form.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="count"
    ></el-pagination>
  </div>
</template>
<script>
import { getScheduleapi } from "@/api/area/Schedule";

export default {
  data() {
    return {
      multipleSelection: [],
      tableData: [],
      form: {
        pageIndex: 1,
        pageSize: 2,
        quyu: "",
        name: "",
      },
      count: 0,
    };
  },
  created() {
    this.load();
  },
  methods: {
    load() {
      getScheduleapi(this.form).then((res) => {
        this.tableData = res.data.data;
        this.count = res.data.totalCount;
      });
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleSizeChange(val) {
      this.form.pageSize = val;
      this.load();
    },
    handleCurrentChange(val) {
      this.form.pageIndex = val;
      this.load();
    },
    fantian(id) {
      alert(id);
    },
    shanchu(id) {
      alert(id);
    },
  },
};
</script>